package day43;

import java.util.*;

/**
 * 功能描述
 *
 * @author wileda
 * @date 2023/04/23  21:19
 */
public class Main {
   static Map<Integer,String> map = new HashMap<>();
    public static void main(String[] args) {
        map.put(2,"ABC");
        map.put(3,"DEF");
        map.put(4,"GHI");
        map.put(5,"JKL");
        map.put(6,"MNO");
        map.put(7,"PQRS");
        map.put(8,"TUV");
        map.put(9,"WXYZ");
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            String[] str = new String[n];
            Set<String> set = new HashSet<>();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < str.length; i++) {
                str[i] = scanner.next();
            }

            for (String strs: str) {
                fing(strs,sb);
                set.add(sb.toString());
                sb.delete(0,sb.length());
            }
            String[] results = set.toArray(new String[set.size()]);
            Arrays.sort(results);
            for (String result: results) {
                System.out.println(result);
            }
            System.out.println();
        }
    }

    private static void fing(String str, StringBuffer sb) {
        int len = 0;
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            String strCh = ch + "";
            if(ch >= '0' && ch <= '9'){
                if(len == 3){
                    sb.append("-" + strCh);
                }else {
                    sb.append(strCh);
                }
                len++;
                continue;
            }
            for (int j = 2; j <= 9 ; j++) {
                String word = map.get(j);
                if(word.contains(strCh)){
                    if(len == 3){
                        sb.append("-" + j);
                    }else {
                        sb.append(j);
                    }
                    len++;
                    break;
                }
            }
        }
    }
}
